import bus from "@/bus";
let data = {
	status: 'pass',
	totalItem: 1,
	pageSize: window.$pageSize,
  currentPage: 1,
  isBind: null,
  form: {
    materialName: '',
    materialBrand: '',
    materialSpec: '',
    materialFigure: '',
    materialLayer: ''
  },
  columns: [{
		type: 'selection',
		width: 60,
		align: 'left'
	}, {
    title: '编号',
    align: 'left',
    key: 'materialSn',
    minWidth: 200
  }, {
    title: '名称',
    key: 'materialName',
    minWidth: 250,
    tooltip: true
  }, {
    title: '品牌',
    align: 'left',
    key: 'materialBrand',
    minWidth: 150,
    tooltip: true
  }, {
    title: '规格',
    align: 'left',
    key: 'materialSpec',
    minWidth: 150,
    tooltip: true
  }, {
    title: '花纹',
    align: 'left',
    key: 'materialFigure',
    minWidth: 150,
    tooltip: true
  }, {
    title: '层级',
    align: 'left',
    minWidth: 80,
    key: 'materialLayer'
  }, {
    title: '已绑商品',
    align: 'left',
    key: 'productCenterName',
    minWidth: 150,
    render: (h, p) => <span>{p.row.productCenterName || '--'}</span>
  }, {
    title: '绑定状态',
    align: 'left',
    minWidth: 120,
    key: 'productCenterId',
    filters: [{
      label: '未绑定',
      value: 1
    }, {
      label: '已绑定',
      value: 2
    }],
    filterMultiple: false,
    filterRemote(data, key) {
      bus.$emit('changeState', { data: data, key });
    },
    render: (h, params) => {
      let text = params.row.productCenterId ? '已绑定' : '未绑定';
      let className = !params.row.productCenterId ? 'font-red' : 'font-blue';
      return h('div', {
        class: className
      }, text)
    }
  }, {
    title: '需绑定',
    minWidth: 100,
    render: (h, p) => {
      let openSlot = h('span', {
        slot: 'open'
      }, '开')
      let closeSlot = h('span', {
        slot: 'close'
      }, '关')
      return h('i-switch', {
        props: {
          type: 'primary',
          value: p.row.needBind
        },
        on: {
          'on-change': () => {
            bus.$emit('onSwitch', {row: p.row, type: 1})
          }
        }
      }, [openSlot, closeSlot])
    }
  }, {
    title: '操作',
    align: 'right',
    minWidth: 80,
    fixed: 'right',
    render:(h, params)=>{
      let bindBtn = h('Button', {
        props:{
          size:'small',
          type:'primary'
        },
        on: {
          click: () => {
            bus.$emit('onBind', {row: params.row})
          }
        }
      }, '绑定')
      let notBindBtn = h('Button', {
        props:{
          size:'small'
        },
        on: {
          click: () => {
            bus.$emit('onNotBind', {row: params.row})
          }
        }
      }, '解绑')
      if (params.row.productCenterId) {
        return h('div',[notBindBtn])
      } else {
        return h('div',[bindBtn])
      }
    }
  }],
  data: []
}
export default data;